package com.tuanzi.loan.business.service.family.impl;

import com.tuanzi.loan.business.entity.family.LoanWholeSaleComment;
import com.tuanzi.loan.business.repository.family.LoanLargeAmountPlusRecordRepository;
import com.tuanzi.loan.business.service.family.LoanLargeAmountPlusRecordService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.family.LoanLargeAmountPlusRecordSearchRequest;
import com.tuanzi.loan.vo.response.family.LoanLargeAmountPlusRecordSearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Debug
@Service
@Transactional
@Retryable(value = {RetryException.class})
public class LoanLargeAmountPlusRecordServiceImpl implements LoanLargeAmountPlusRecordService{
    @Autowired
    LoanLargeAmountPlusRecordRepository loanLargeAmountPlusRecordRepository;
    @Override
    public Page<LoanLargeAmountPlusRecordSearchResponse> list(PageSearcher<LoanLargeAmountPlusRecordSearchRequest> pageSearcher) {
        return loanLargeAmountPlusRecordRepository.list(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
    }

    @Override
    public List<String> getCfrom() {
        return loanLargeAmountPlusRecordRepository.getCfrom();
    }

    @Override
    public List<LoanWholeSaleComment> getTypeOwnner() {
        return loanLargeAmountPlusRecordRepository.getTypeOwnner();
    }

    @Override
    public List<LoanWholeSaleComment> getWaiTuiProduct() {
        List<LoanWholeSaleComment> typeOwnner = this.getTypeOwnner();
        return typeOwnner.stream().filter(x ->"是".equals(x.getWaitui())).collect(Collectors.toList());
    }

    @Override
    public List<String> getZhanNeiCFrom() {
        return loanLargeAmountPlusRecordRepository.getZhanNeiCFrom();
    }
}
